import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index'
import User from '../views/user/index.vue'
import add from '../views/user/add.vue'
import login from '../views/user/login.vue'
import Item from '../views/item/index'
import VantIndex from '../views/vant/index'
import xingIndex from '../views/xing/index'
Vue.use(VueRouter)

const routes = [
  { path: '/xing', component: xingIndex },
  { path: '/', component: VantIndex },
  { path: '/item', component: Item },
  { path: '/index', component: Index },
  {
    path: '/user',
    name: 'User',
    component: User,
    children: [
      { path: 'add', component: add},
      {path: 'login',component: login}
    ]
  },
]

const router = new VueRouter({
  routes
})

const VueRouterPush = VueRouter.prototype.push

VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router
